<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>基础表单</title>
    <link rel="stylesheet" href="__LIBS__/layui/css/layui.css" />
    <link rel="stylesheet" href="__MODULE__/admin.css?v=317" />
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        #formBasForm {
            width: 800px;
        }

        .layui-form-item {
            display: flex;
        }


        .layui-input-block {
            flex: 14;
        }

        .layui-input-block {
            margin-left: 20px !important;
            min-height: 36px;
        }

        .pictureNomer {
            flex: 7;
            height: 38px;
            line-height: 38px;
            margin-right: 5px;
        }
        .layui-upload-img {

            max-height: 200px;
            height: auto;
            margin: 0 10px 10px 0;
            cursor:pointer;
        }
        .imgs-box{
            display: flex;
        }
        #formBasForm .layui-form-item {
            margin-bottom: 25px;
        }
    </style>
</head>

<body>
    <!-- 加载动画 -->
    <div class="page-loading">
        <div class="ball-loader">
            <span></span><span></span><span></span><span></span>
        </div>
    </div>
    <!-- 正文开始 -->
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 表单开始 -->
                <form class="layui-form" id="formBasForm" lay-filter="formBasForm">
                    <div class="layui-form-item">
                        <label class="layui-form-label layui-form-required">请设置分销方式:</label>
                        <div class="layui-input-block">
                            <input type="radio" name="fx_type" value="1" title="全场分销" {if $item['fx_type']=='1' }checked="checked"{/if}>
                            <input type="radio" name="fx_type" value="2" title="指定分销商品 " {if $item['fx_type']=='2' }checked="checked"{/if}>
                            <input type="radio" name="fx_type" value="0" title="关闭" {if $item['fx_type']=='0' }checked="checked"{/if}>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label layui-form-required">是否自动成为分销商:</label>
                        <div class="layui-input-block">
                            <input type="radio" name="fx_auto" value="1" title="是" {if $item['fx_auto']=='1' }checked="checked"{/if}>
                            <input type="radio" name="fx_auto" value="0" title="否 " {if $item['fx_auto']=='0' }checked="checked"{/if}>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label layui-form-required">成为分销商支付金额(需关闭自动成为分销商):</label>
                        <div class="layui-input-block">
                            <input name="fxs2price" class="layui-input" value="{$item['fxs2price']}" lay-verify="required" required />
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label layui-form-required">分销佣金比例(请输入1-100之间的两位整数):</label>
                        <div class="layui-input-block">
                            <div style="display: flex;">
                                <div style="display: flex; margin-right: 20px;justify-content: center;align-items: center; ">
                                    <p class="pictureNomer">直推</p><input type="number" name="ztyj" id="ztyj" class="layui-input"
                                        style="flex: 15;" lay-verify="required" required min="0" placeholder="20" value="{php}echo $item['ztyj']*100;{/php}" /><span>&nbsp;&nbsp;%</span>
                                </div>
                                <div style="display: flex;justify-content: center;align-items: center; ">
                                    <p class="pictureNomer">间推</p><input type="number" name="jtyj" id="jtyj" class="layui-input"
                                        style="flex: 15;" lay-verify="required" required min="0" placeholder="10" value="{php}echo $item['jtyj']*100;{/php}" /><span>&nbsp;&nbsp;%</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label layui-form-required">讲师佣金比例(请输入1-100之间的两位整数):</label>
                        <div class="layui-input-block">
                            <div style="display: flex;">
                                <div style="display: flex; margin-right: 20px;justify-content: center;align-items: center; ">
                                    <p class="pictureNomer">讲师佣金</p><input type="number" name="jsyj" id="jsyj" class="layui-input"
                                                                         style="flex: 15;" lay-verify="required" required min="0" placeholder="20" value="{php}echo $item['jsyj']*100;{/php}" /><span>&nbsp;&nbsp;%</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label layui-form-required">最低提现金额:</label>
                        <div class="layui-input-block">
                            <input name="tx_min" class="layui-input" lay-verify="required" value="{$item['tx_min']}" required />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label ">分销海报(宽600px,高1000px):</label>
                        <div class="layui-input-block">
                            <div style="display: flex;">
                                <div class="imgs-box">
                                    <input type="hidden" name="fxhb1" id="fxhb1_input" value="{$item['fxhb1']?$item['fxhb1']:''}">
                                    <div class="layui-upload layui-input-block">
                                        <button type="button" class="layui-btn imgupload" id="fxhb1"><i class="layui-icon">&#xe67c;</i> 上传图片</button>
                                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                            预览图：
                                            <div class="layui-upload-list" >
                                                <img class="layui-upload-img" src="{$item['fxhb1']? to_media_url($item['fxhb1']):''}" id="fxhb1_demo1">
                                                <p id="fxhb1_demoText"></p>
                                            </div>
                                        </blockquote>
                                    </div>
                                </div>
                                <div class="imgs-box">
                                    <input type="hidden" name="fxhb2" id="fxhb2_input" value="{$item['fxhb2']?$item['fxhb2']:''}">
                                    <div class="layui-upload layui-input-block">
                                        <button type="button" class="layui-btn imgupload" id="fxhb2"><i class="layui-icon">&#xe67c;</i> 上传图片</button>
                                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                            预览图：
                                            <div class="layui-upload-list" >
                                                <img class="layui-upload-img" src="{$item['fxhb2']?to_media_url($item['fxhb2']):''}" id="fxhb2_demo1">
                                                <p id="fxhb2_demoText"></p>
                                            </div>
                                        </blockquote>
                                    </div>
                                </div>
                                <div class="imgs-box">
                                    <input type="hidden" name="fxhb3" id="fxhb3_input" value="{$item['fxhb3']?$item['fxhb3']:''}">
                                    <div class="layui-upload layui-input-block">
                                        <button type="button" class="layui-btn imgupload" id="fxhb3"><i class="layui-icon">&#xe67c;</i> 上传图片</button>
                                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                            预览图：
                                            <div class="layui-upload-list" >
                                                <img class="layui-upload-img" src="{$item['fxhb3']?to_media_url($item['fxhb3']):''}" id="fxhb3_demo1">
                                                <p id="fxhb3_demoText"></p>
                                            </div>
                                        </blockquote>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品分享海报(宽750px,高1334px):</label>
                        <div class="layui-input-block">
                            <div style="display: flex; ">
                                <div class="imgs-box">
                                    <input type="hidden" name="goodshb1" id="goodshb1_input" value="{$item['goodshb1']?$item['goodshb1']:''}">
                                    <div class="layui-upload layui-input-block">
                                        <button type="button" class="layui-btn imgupload" id="goodshb1"><i class="layui-icon">&#xe67c;</i> 上传图片</button>
                                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                            预览图：
                                            <div class="layui-upload-list" >
                                                <img class="layui-upload-img" src="{$item['goodshb1']?to_media_url($item['goodshb1']):''}" id="goodshb1_demo1">
                                                <p id="goodshb1_demoText"></p>
                                            </div>
                                        </blockquote>
                                    </div>
                                </div>
                                <div class="imgs-box">
                                    <input type="hidden" name="goodshb2" id="goodshb2_input" value="{$item['goodshb2']?$item['goodshb2']:''}">
                                    <div class="layui-upload layui-input-block">
                                        <button type="button" class="layui-btn imgupload" id="goodshb2"><i class="layui-icon">&#xe67c;</i> 上传图片</button>
                                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                            预览图：
                                            <div class="layui-upload-list" >
                                                <img class="layui-upload-img" src="{$item['goodshb2']?to_media_url($item['goodshb2']):''}" id="goodshb2_demo1">
                                                <p id="goodshb2_demoText"></p>
                                            </div>
                                        </blockquote>
                                    </div>
                                </div>
                                <div class="imgs-box">
                                    <input type="hidden" name="goodshb3" id="goodshb3_input" value="{$item['goodshb3']?$item['goodshb3']:''}">
                                    <div class="layui-upload layui-input-block">
                                        <button type="button" class="layui-btn imgupload" id="goodshb3"><i class="layui-icon">&#xe67c;</i> 上传图片</button>
                                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                            预览图：
                                            <div class="layui-upload-list" >
                                                <img class="layui-upload-img" src="{$item['goodshb3']?to_media_url($item['goodshb3']):''}" id="goodshb3_demo1">
                                                <p id="goodshb3_demoText"></p>
                                            </div>
                                        </blockquote>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">海报合成语:</label>
                        <div class="layui-input-block">
                            <input name="hbtext" class="layui-input" value="{$item['hbtext']}" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">分享提示语:</label>
                        <div class="layui-input-block">
                            <input name="share_hbtext" class="layui-input" value="{$item['share_hbtext']}"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">提现提示语:</label>
                        <div class="layui-input-block">
                            <input name="txtext" class="layui-input" value="{$item['txtext']}" />
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block" style="display: flex;
                    justify-content: space-around;
                ">
                            <button id="btnDemoEdtGetContent" class="layui-btn submitbtn" lay-filter="formBasSubmit"
                                lay-submit>&emsp;提交&emsp;</button>
                            <button type="reset" class="layui-btn layui-btn-primary">&emsp;重置&emsp;</button>
                        </div>
                    </div>
                </form>
                <!-- //表单结束 -->
            </div>
        </div>
    </div>

    <!-- js部分 -->
    <script type="text/javascript" src="__LIBS__/layui/layui.js"></script>
    <script type="text/javascript" src="__NJS__/common.js?v=317"></script>
    <script type="text/javascript" src="__LIBS__/tinymce/tinymce.min.js"></script>
    <script src="__LIBS__/jquery/jquery-3.2.1.min.js"></script>
    <script>

        layui.use(['layer', 'form', 'laydate', 'jquery','upload','admin'], function () {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;
            var laydate = layui.laydate;
            var upload = layui.upload;
            var admin = layui.admin;
            //普通图片上传
            var uploadInst = upload.render({
                elem: '.imgupload'
                ,url: "{:url('admin/Upload/uploadLocal')}" //改成您自己的上传接口
                ,before: function(obj){
                    var item = this.item;
                    var e=item[0].id
                    //预读本地文件示例，不支持ie8
                    obj.preview(function(index, file, result){
                        $('#'+e+'_demo1').attr('src', result); //图片链接（base64）
                    });
                }
                ,done: function(res,index,upload){
                    console.log(res)
                    var item = this.item;
                    var e=item[0].id
                    //如果上传失败
                    if(res.code == 0){
                        $("#"+e+"_input").val(res.data);
                        var demoText = $('#'+e+'_demoText');
                        demoText.html('<span style="color: #01AAED;"><i class="layui-icon">&#x1005;</i>上传成功</span>');
                    }
                    //上传成功
                }
                ,error: function(){
                    //演示失败状态，并实现重传
                    var item = this.item;
                    var e=item[0].id
                    var demoText = $('#'+e+'_demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span>');
                }
            });


            /* 监听表单提交 */
            form.on('submit(formBasSubmit)', function (data) {
                var ztyj=$("#ztyj").val();
                var jtyj=$("#jtyj").val();
                var jsyj=$("#jsyj").val();
                if((ztyj>=100 || ztyj<=0) || (jtyj>=100 || jtyj<=0) || (jsyj>=100 || jsyj<=0)){
                    layer.msg('佣金比例请输入1-100之间的两位整数');
                    return false;
                }else if(Number(ztyj)+Number(jtyj)+Number(jsyj)>100){

                    layer.msg('直推、间推、讲师佣金比例总和不能大于100');
                    return false;
                }
                else{
                    $('.submitbtn').addClass('layui-disabled').attr('disabled','disabled');
                    $.ajax({
                        url:"{:url('fenxiao')}",
                        type:'post',
                        dataType:'json',
                        data:data.field,
                        success:function(res){
                            //console.log(res)
                            if (res.code == 0) {
                                layer.msg(res.msg,{icon:1,time:1500,shade:0.1})
                                setTimeout(function () {
                                    admin.closeThisTabs();
                                }, 1000);
                            } else {
                                $(".layui-btn").removeClass('layui-disabled').removeAttr('disabled');
                                wk.error(res.msg);
                                return false;
                            }
                        }
                    })
                }
            });


        });
    </script>
</body>

</html>